<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, maximum-scale=1, user-scalable=no,viewport-fit=cover">
    <link href="css/common.css" rel="stylesheet">
    <style>
        .form-group{
            background: #fff;
            border-bottom: 2px solid #eee;
            padding: 15px 0;
        }
        .form-text{
            display: inline-block;
            text-align:right;
        }
    </style>

</head>
<body>
<div class="head-nav">
    <div class="nav-left" onclick="javascript:history.back(-1)"><img src="img/gua/u18.png"></div>
    <div class="nav-title">个人信息</div>
</div>
<div class="main">
    <div class="form-group">
        <label class="wd-30 form-text">真实姓名：</label>
        <span id="real_name"></span>
    </div>
    <div class="form-group">
        <label class="wd-30 form-text">身份证号：</label>
        <span id="id_card"></span>
    </div>
    <div class="form-group">
        <label class="wd-30 form-text">手机号码：</label>
        <span id="phoneNum"></span>
    </div>
    <div style="height: 10vw"></div>

    <div class="btn-line" onclick="goEdit()">修改信息</div>
</div>


<script src="js/jquery-1.8.0.min.js"></script>
<script src="js/common.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="https://cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>

<script type="application/javascript">
    $(function () {
        getopenid();
        loadInfo();
    });
    var openid;
    function getopenid() {
        openid = window.localStorage.getItem("openid");
        if(openid == null || openid == undefined || openid == '') {
            getCode();
        }
    }
    function getCode() {
        var code = Common.queryGetParam('code');
        if(code == null || code == undefined || code == '') {
            location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx95bdc635798fcfe4&redirect_uri="+window.location.href+"&response_type=code&scope=snsapi_base#wechat_redirect";
            return;
        }
        var paramStr = {};
        paramStr.code = code;
        var params = {};
        params.paramStr = JSON.stringify(paramStr);
        Common.ajaxWithParam("/fenful/api/v1/common/getWxUserOpenId", params, function(data) {
            openid = data.openid;
            window.localStorage.setItem("openid", data.openid);
        },false);
    }
    function loadInfo(){
        var paramStr = {};
        paramStr.wxOpenId = openid;
        var params = {};
        params.paramStr = JSON.stringify(paramStr);
        Common.ajaxWithParam("/fenful/api/v1/login/getUserByOpenId", params, function(data) {
            if(data.real_name||data.id_card){
                $(".btn-line").hide();
            }else{
                $(".btn-line").show();
            }
            $("#real_name").text(data.real_name);
            var id_card = data.id_card;
            if(id_card){
                id_card = id_card.substr(0,3)+"************"+id_card.substr(id_card.length-3,3);
                $("#id_card").text(id_card);
            }
            var phoneNum = data.phoneNum;
            if(phoneNum){
                phoneNum = phoneNum.substr(0,3)+"****"+phoneNum.substr(phoneNum.length-4,4);
                $("#phoneNum").text(phoneNum);
            }

        });
    }

    function goEdit() {
        window.location.href="guaEditUser.html";
    }
</script>    
</body>
</html>